﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebUI.Models;
using WebUI.BL.User;
namespace WebUI
{
    public partial class UserManager : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var gridUsers = GetUserGridViewModel();
                ShowGridview(gridUsers);
            }
        }

        private List<UserGridViewModel> GetUserGridViewModel()
        {
            UserBL userbl=new UserBL();
            var objView = from userViewModel in userbl.GetUsers()
                          select new UserGridViewModel
                          {
                              Id = userViewModel.UserNo,
                              Name = userViewModel.Name,
                              Status = userViewModel.Status
                          };
            return objView.ToList();
        }

        private void ShowGridview(List<UserGridViewModel> gridUsers)
        {
            gridViewUsers.DataSource = gridUsers;
            DataBind();
        }

        
    }
}